local mingfa = fk.CreateSkill {
  name = "lingling__mingfa",
}

Fk:loadTranslationTable{
  ["lingling__mingfa"] = "明罚",
  [":lingling__mingfa"] = "出牌阶段限一次，你可以对一名角色造成1点伤害，本阶段结束时其回复1点体力。不能连续选择同一名角色。",

  ["#lingling__mingfa"] = "明罚：对一名角色造成1点伤害，本阶段结束时其回复1点体力",
}

mingfa:addEffect("active", {
  anim_type = "offensive",
  prompt = "#lingling__mingfa",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(mingfa.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected, cards)
    return #selected == 0 and player:getMark(mingfa.name) ~= to_select.id
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:setPlayerMark(player, mingfa.name, target.id)
    room:addPlayerMark(target, "lingling__mingfa-phase", 1)
    room:damage{
      from = player,
      to = target,
      damage = 1,
      skillName = mingfa.name,
    }
  end,
})

mingfa:addEffect(fk.EventPhaseEnd, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function (self, event, target, player, data)
    return player:getMark("lingling__mingfa-phase") > 0
  end,
  on_use = function (self, event, target, player, data)
    player.room:recover{
      who = player,
      num = player:getMark("lingling__mingfa-phase"),
      recoverBy = player,
      skillName = mingfa.name,
    }
  end,
})

return mingfa